package spring.cloud.tasks.common;

import com.alibaba.fastjson2.annotation.JSONField;
import lombok.Getter;
import lombok.Setter;
import lombok.extern.slf4j.Slf4j;
import spring.cloud.tasks.common.task_item_allot.TaskItem;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

@Slf4j
@Setter
@Getter
public class BatchTaskInstanceInfo {
    public static final String status_init = "init";
    public static final String status_data_splitting = "data_splitting";//串行
    public static final String status_data_split_success = "data_split_success";
    public static final String status_data_split_fail = "data_split_fail";//是否需要进行重跑
    public static final String status_data_split_timeout = "data_split_timeout";
    //
    public static final String status_task_execute_and_status_collecting = "task_execute_and_status_collecting";//并行
    public static final String status_task_execute_and_status_collecting_success = "task_execute_and_status_collecting_success";
    public static final String status_task_execute_and_status_collecting_fail = "task_execute_and_status_collecting_fail";
    public static final String status_task_execute_and_status_collecting_timeout = "task_execute_and_status_collecting_timeout";
    //
    public static final String status_data_post_handing = "data_post_handing";//串行
    public static final String status_data_post_hand_success = "data_post_hand_success";
    public static final String status_data_post_hand_fail = "data_post_hand_fail";//是否需要进行重跑
    public static final String status_data_post_hand_timeout = "data_post_hand_timeout";
    //
    public static final String status_finished = "finished";
    public static final int task_item_index_splitting = -1;
    public static final int task_item_index_collecting = -11;
    public static final int task_item_index_post_handing = -111;
    private String taskId;
    private String taskType;
    private String taskInstanceId;
    private String taskRoundId;
    private String stage;
    @JSONField(name = "nextFireDate", format = "yyyy-MM-dd HH:mm:ss")
    private Date nextFireDate;//指的是可以触发的时间
    @JSONField(name = "timeoutDateTime", format = "yyyy-MM-dd HH:mm:ss")
    private Date timeoutDateTime;//超时时间
    @JSONField(name = "lockDateTime")
    private Date lockDateTime;//锁时间 lockDateTime>timeoutDateTime 每个时间片需要详细记录对应的时间  因为这个是多实例，即最新的分配信息 不一定是最新的分配信息

    //taskItemList 临时性质的,主要保留拆分程序和收集程序
    private boolean restartAssignTaskItemPlanCreate = false;//重启的时候进行判断
    private Boolean rebuildAssignTaskItemPlanCreate = null;//正常批次任务进行状态改变的时候标记 null什么也不做/true需要更新执行计划/false代表结束了
    List<TaskItem> taskItemList = new ArrayList<>();
}
